<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="utf-8">
    <title>配置项管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="/layui/css/eleTree.css"  media="all">
</head>
<body>
<!-- <div id="oneCheck" style="display:none">
	<span>hehehehehe</span>
</div> -->
<div class="layui-container">
    <form class="layui-form layui-form-pane" id="form1">
        <!-- 第1行 -->
        <input type="hidden" id="id" name="id" th:value="${pro?.id}"/>

        <!-- 第2行 -->
        <div class="layui-row">
            <div class="layui-col-md5 layui-col-md-offset3">
                <div class="layui-form-item">
                    <label class="layui-form-label">服务器ip</label>
                    <div class="layui-input-block" >
                        <input   type="text" name="server_addr" id="server_addr" lay-verify="required"  autocomplete="off" placeholder="请输入服务器ip或者域名" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <!-- 第5行 -->
        <div class="layui-row">
            <div class="layui-col-md5 layui-col-md-offset3">
                <div class="layui-form-item">
                    <label class="layui-form-label">服务器端口</label>
                    <div class="layui-input-block" >
                        <input   type="text" name="server_port" id="server_port" lay-verify="required"  autocomplete="off" placeholder="请输入服务器端口" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <!-- 第2行 -->
        <div class="layui-row">
            <div class="layui-col-md5 layui-col-md-offset3">
                <div class="layui-form-item">
                    <label class="layui-form-label">token</label>
                    <div class="layui-input-block" >
                        <input   type="text" name="token" id="token" lay-verify="required"  autocomplete="off" placeholder="请输入服务器端口" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <!-- 第2行 -->
        <div class="layui-row">
            <div class="layui-col-md5 layui-col-md-offset3">
                <div class="layui-form-item">
                    <label class="layui-form-label">SSH-ip</label>
                    <div class="layui-input-block" >
                        <input   type="text" name="local_ip" id="local_ip" lay-verify="required"  autocomplete="off" placeholder="请输入SSH-ip" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <!-- 第2行 -->
        <div class="layui-row">
            <div class="layui-col-md5 layui-col-md-offset3">
                <div class="layui-form-item">
                    <label class="layui-form-label">SSH-端口</label>
                    <div class="layui-input-block" >
                        <input   type="text" name="local_port" id="local_port" lay-verify="required"  autocomplete="off" placeholder="请输入SSH-端口" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <!-- 第2行 -->
        <div class="layui-row">
            <div class="layui-col-md5 layui-col-md-offset3">
                <div class="layui-form-item">
                    <label class="layui-form-label">SSH-远程端口</label>
                    <div class="layui-input-block" >
                        <input type="input" name="remote_port" id="remote_port"  lay-verify="required" autocomplete="off" placeholder="请输入SSH-远程端口" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <!-- 按钮 -->
        <div class="layui-row">
            <div class="layui-col-md5 layui-col-md-offset3 ">
                <div class="layui-col-md12 ">
                    <button type="submit" class="layui-btn layui-btn-normal  layui-btn-fluid onSave" lay-submit="" lay-filter="demo1"><i class="layui-icon layui-icon-ok-circle"></i><span th:text="${#strings.isEmpty(pro)}?'保存':'更新'"></span></button>
                    <!--<button type="button" class="layui-btn layui-btn-normal  layui-btn-fluid onSave"><i class="layui-icon layui-icon-ok-circle"></i><span th:text="${#strings.isEmpty(pro)}?'保存':'更新'"></span></button>-->
                </div>
            </div>
        </div>
    </form>
</div>
<script src="/layui/layui.all.js" charset="utf-8"></script>
<script type="text/javascript">
    layui.use(['form', 'layedit', 'laydate','element','jquery','tree','upload'], function() {
        var form = layui.form,
            layer = layui.layer,
            element=layui.element,
            laydate = layui.laydate,
            $=layui.jquery;
        $.ajax({
            type:'GET',
            url:'/frpc/common/get',
            success:function(data){
                if(data.code == 0){
                    $('#local_ip').val(data.data.local_ip);
                    $('#local_port').val(data.data.local_port);
                    $('#remote_port').val(data.data.remote_port);
                    $('#server_addr').val(data.data.server_addr);
                    $('#server_port').val(data.data.server_port);
                    $('#token').val(data.data.token);
                }else{
                    layer.msg(data.msg)
                }
            }
        })



        form.on('submit(demo1)', function(data) {
            //data.field 是一个json对象,批量获取表单的值{'表单的name':'对应的值'}
            var form1 = $("#form1").serialize();
            //layer.msg(JSON.stringify(data.field));
            //var checkData = tree.getChecked('demoId');
            $.ajax({
                type:'POST',
                url:'/frpc/common/update',
                data:form1,
                success:function(data){
                    if(data.code == 0){
                        layer.confirm('提交成功!!!!', {
                            btn: ['确定'] //可以无限个按钮
                        }, function(index, layero){
                            window.location.reload();
                        },);
                    }else{
                        layer.msg(data.msg)
                    }
                }
            })
            //return false 可以阻止 表单提交(刷新页面)
            return false;
        });

    });
</script>
</body>
</html>